import collections
class Solution(object):
    def minMeetingRooms(self, intervals):
        """
        :type intervals: List[List[int]]
        :rtype: int
        """
        intervals.sort()
        room = collections.deque()
        room.append(intervals[0][1])
        for i in range(1, len(intervals)):
            flag = True
            for j in range(len(room)):
                if intervals[i][0] >= room[j]:
                    room[j] = intervals[i][1]
                    flag = False
                    break
            if flag:
                room.append(intervals[i][1])
        return len(room)



data = Solution()
intervals = [(1, 10), (2, 7), (3, 19), (8, 12), (10, 20), (11, 30)]
print(data.minMeetingRooms(intervals))